package com.ruoyi.camp.service.impl;

import java.util.List;

import com.ruoyi.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.camp.mapper.CampsiteMapper;
import com.ruoyi.camp.domain.Campsite;
import com.ruoyi.camp.service.ICampsiteService;

/**
 * 营位Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-05
 */
@Service
public class CampsiteServiceImpl implements ICampsiteService 
{
    @Autowired
    private CampsiteMapper campsiteMapper;

    /**
     * 查询营位
     * 
     * @param campsiteid 营位主键
     * @return 营位
     */
    @Override
    public Campsite selectCampsiteByCampsiteid(String campsiteid)
    {
        return campsiteMapper.selectCampsiteByCampsiteid(campsiteid);
    }

    /**
     * 查询营位列表
     * 
     * @param campsite 营位
     * @return 营位
     */
    @Override
    public List<Campsite> selectCampsiteList(Campsite campsite)
    {
        return campsiteMapper.selectCampsiteList(campsite);
    }

    /**
     * 新增营位
     * 
     * @param campsite 营位
     * @return 结果
     */
    @Override
    public int insertCampsite(Campsite campsite)
    {
        campsite.setCampsiteid(IdUtils.randomUUID());
        return campsiteMapper.insertCampsite(campsite);
    }
    @Override
    public int insertCampsite(Campsite[] campsites)
    {
        //随机id
        for (Campsite campsite : campsites) {
            campsite.setCampsiteid(IdUtils.randomUUID());
            campsiteMapper.insertCampsite(campsite);
        }
        return 1;
    }

    /**
     * 修改营位
     * 
     * @param campsite 营位
     * @return 结果
     */
    @Override
    public int updateCampsite(Campsite campsite)
    {
        return campsiteMapper.updateCampsite(campsite);
    }

    /**
     * 批量删除营位
     * 
     * @param campsiteids 需要删除的营位主键
     * @return 结果
     */
    @Override
    public int deleteCampsiteByCampsiteids(String[] campsiteids)
    {
        return campsiteMapper.deleteCampsiteByCampsiteids(campsiteids);
    }

    /**
     * 删除营位信息
     * 
     * @param campsiteid 营位主键
     * @return 结果
     */
    @Override
    public int deleteCampsiteByCampsiteid(String campsiteid)
    {
        return campsiteMapper.deleteCampsiteByCampsiteid(campsiteid);
    }
}
